package com.gxa.meiye.admin.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxa.meiye.admin.mapper.CouponMapper;
import com.gxa.meiye.admin.service.ICouponService;
import com.gxa.meiye.core.pojo.domain.Coupon;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 优惠卷 服务实现类
 * </p>
 *
 * @author zy
 * @since 2022-07-24
 */
@Service
public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> implements ICouponService {
    @Autowired
    private CouponMapper couponMapper;

    @Override
    public List<Coupon> list(String phone) {
        List<Coupon> selcet = couponMapper.selcet(phone);

        return selcet;
    }

    @Override
    public Integer update(String title, String phone) {
        Integer integer = couponMapper.selectConupon(phone, title);
        //兑换后数量减一
        integer--;
        Integer update = couponMapper.update(integer, phone, title);
        return update;
    }
}
